package com.yuexun.dhdoctor.module.main.presenter.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.main.bean.TaskCountData;
import com.yuexun.dhdoctor.module.main.model.IMessageModel;
import com.yuexun.dhdoctor.module.main.presenter.ISysRemindPresenter;
import com.yuexun.dhdoctor.module.main.ui.view.ISysRemindView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2017/4/25 0025.
 */

public class SysRemindPresenter implements ISysRemindPresenter {

    private ISysRemindView view;
    private IMessageModel model;

    public SysRemindPresenter(IMessageModel model, ISysRemindView view) {
        this.model = model;
        this.view = view;
    }

    @Override
    public void getUnReadSysRemindCount(Map<String, String> praise) {
        model.getUnReadSysRemindCount(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<TaskCountData>>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
//                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(BaseEntity<TaskCountData> messageCountBean) {
                        view.showSysRemindCount(messageCountBean);
                    }
                });
    }
}
